<?php

if ($_SERVER["REQUEST_METHOD"] == "GET") {
    print_r(json_encode(array("msg" => "不支持get请求", "status" => -1)));
    return;
}

// session_start();
// if(!isset($_SESSION["usermessage"])){
//     $result=array("msg"=>"请先登录","status"=>-2);
//     print_r(json_encode($result));
//     return;
// }

$cid = $_REQUEST["cid"];
$size2=$_REQUEST["size2"];

include "./DBhelper.php";


$sql="SELECT * FROM `carslist` WHERE  `id`='".$cid."' AND `size2`='".$size2."'";
$resultData1=sqlQuery($sql);

if($resultData1->num_rows>=1){
    $result=array("msg" => "修改失败", "status" => -2);
    print_r(json_encode($result));
}else{
    $update = "UPDATE `carslist` SET size2='".$size2."' WHERE id='".$cid."'";
    $resultData = sqlQuery($update); //更新的结果
    if ($resultData == 1) {
        $result=array("msg" => "修改成功", "status" => 1);
        print_r(json_encode($result));
    } else {
        $result=array("msg" => "修改失败", "status" => -3);
        print_r(json_encode($result));
    }
}
